<center><h2>任务主页</h2></center>

<center>
    <a class="btn btn-primary" href="index.php?controller=Users&action=index"><?php echo USER; ?>的主页</a>
    <a class="btn btn-primary" href="index.php?controller=Users&action=logout">注销</a>
</center>
<p><?php if(isset($status) && $status == false) { echo $message;} else { ?></p>
<center>
    <div class="container" style="max-width: 290px;">
        <form action="index.php?controller=Task&action=searchTask" method="post" class="form-inline">
            <input type="search" class="form-control" id="search"   name="keyword" placeholder="搜索">
            <button type="submit" class="btn btn-primary" style="margin-left: 4px;">搜索</button>
        </form>
    </div>
    <table class="table table-dark table-hover" style="width: 80%;">
        <thead>
            <tr style="text-align: center;">
                <th>标题</th>
                <th>发布人</th>
                <th>负责人</th>
                <th>任务详情</th>
                <th>完成状态</th>
                <th>领取任务</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($data as $value) { ?>
                <tr style="text-align: center;">
                    <td>
                        <?php echo $value['title']; ?>
                    </td>
                    <td>
                        <?php echo $value['leader']; ?>
                    </td>
                    <td>
                        <?php echo $value['principal']; ?>
                    </td>
                    <td>
                        <?php echo $value['task_info']; ?>
                    </td>
                    <td>
                        <?php echo $value['status'] ? '已完成' : '未完成'; ?>
                    </td>
                    <td style="">
                        <form action="index.php?controller=Task&action=getTask" method="post" style="margin-bottom: 0px;">
                            <input name="title" type="text" value="<?php echo $value['title']; ?>" style="box-shadow: dark;" hidden />
                            <center><button type="submit" class="btn btn-primary"<?php echo $value['principal']? 'disabled' : ''; ?>>领取</button></center>
                        </form>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>

<!-- <a href="index.php?controller=Users&action=publishTask">发布任务</a> -->

<div class="container" style="width: 40%;">
  <h2>发布任务</h2>
  <form action="index.php?controller=Task&action=publishTask" method="post">
    <div class="form-group">
      <label for="task_title">标题:</label>
      <input type="text" class="form-control" id="task_title" name="task_title" placeholder="输入标题">
    </div>
    <div class="form-group">
      <label for="task_info">任务详情:</label>
      <textarea class="form-control" rows="5" id="task_info" name="task_info" placeholder="输入任务详情"></textarea>
    </div>
    <button type="submit" class="btn btn-primary">发布</button>
  </form>
</div>
</center>
<?php } ?>